package com.szyportal.web.back.controller.szyportal;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.szyportal.common.annotation.Log;
import com.szyportal.common.enums.BusinessType;
import com.szyportal.custom.domain.WDevelop;
import com.szyportal.custom.service.IWDevelopService;
import com.szyportal.common.core.controller.BaseController;
import com.szyportal.common.core.domain.AjaxResult;
import com.szyportal.common.utils.poi.ExcelUtil;
import com.szyportal.common.core.page.TableDataInfo;

/**
 * 发展历程Controller
 * 
 * @author ruoyi
 * @date 2024-12-03
 */
@Controller
@RequestMapping("/back/custom/develop")
public class WDevelopController extends BaseController
{
    private String prefix = "back/szyportal/develop";

    @Autowired
    private IWDevelopService wDevelopService;

    @RequiresPermissions("system:develop:view")
    @GetMapping()
    public String develop()
    {
        return prefix + "/develop";
    }

    /**
     * 查询发展历程列表
     */
    @RequiresPermissions("system:develop:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(WDevelop wDevelop)
    {
        startPage();
        List<WDevelop> list = wDevelopService.selectWDevelopList(wDevelop);
        return getDataTable(list);
    }

    /**
     * 导出发展历程列表
     */
    @RequiresPermissions("system:develop:export")
    @Log(title = "发展历程", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(WDevelop wDevelop)
    {
        List<WDevelop> list = wDevelopService.selectWDevelopList(wDevelop);
        ExcelUtil<WDevelop> util = new ExcelUtil<WDevelop>(WDevelop.class);
        return util.exportExcel(list, "发展历程数据");
    }

    /**
     * 新增发展历程
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存发展历程
     */
    @RequiresPermissions("system:develop:add")
    @Log(title = "发展历程", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(WDevelop wDevelop)
    {
        return toAjax(wDevelopService.insertWDevelop(wDevelop));
    }

    /**
     * 修改发展历程
     */
    @RequiresPermissions("system:develop:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        WDevelop wDevelop = wDevelopService.selectWDevelopById(id);
        mmap.put("wDevelop", wDevelop);
        return prefix + "/edit";
    }

    /**
     * 修改保存发展历程
     */
    @RequiresPermissions("system:develop:edit")
    @Log(title = "发展历程", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(WDevelop wDevelop)
    {
        return toAjax(wDevelopService.updateWDevelop(wDevelop));
    }

    /**
     * 删除发展历程
     */
    @RequiresPermissions("system:develop:remove")
    @Log(title = "发展历程", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(wDevelopService.deleteWDevelopByIds(ids));
    }
}
